<?php 
global $_W,$_GPC;

$sql = "SELECT * FROM ".tablename('imeepos_runner3_member')." WHERE uniacid = :uniacid AND openid = :openid";
$params = array(':uniacid'=>$_W['uniacid'],':openid'=>$_W['openid']);
$user = pdo_fetch($sql,$params);

$act = trim($_GPC['act']);

if($act == 'post'){
    if(!empty($user['forbid'])){
        $return = array();
        $return['status'] = -1;
        $return['message'] = '系统检测，您已违反本平台相关规则，已被禁止！请联系管理员解封！';
        $return['url'] = $this->createMobileUrl('home');
        $return['data'] = $runner;
        die(json_encode($return));
    }
    
	if(empty($user['mobile']) || empty($user['realname'])){
		$return = array();
		$return['status'] = -1;
		$return['message'] = '请完善您的个人信息！';
		$return['url'] = $this->createMobileUrl('home_edit');
		die(json_encode($return));
	}else{
		$return = array();
		$return['message'] = '请完善您的个人信息！';
		$return['status'] = 0;
		die(json_encode($return));
	}
}

if($act == 'runner'){
	if(empty($user['isrunner'])){
		$return = array();
		$return['status'] = -1;
		$return['message'] = '您还没有认证您的个人信息，请前往认证！';
		$return['url'] = $this->createMobileUrl('v');
		die(json_encode($return));
	}else{
		$sql = "SELECT * FROM ".tablename('imeepos_runner3_member')." WHERE openid = :openid AND uniacid = :uniacid ";
		$params = array(':openid'=>$_W['openid'],':uniacid'=>$_W['uniacid']);
		$runner = pdo_fetch($sql,$params);
		$xinyu = intval($runner['xinyu']);
		
		//检查信誉值
		//获取后台设置
		$table = "imeepos_runner3_setting";
		$code = 'v_set';
		
		$sql = "SELECT * FROM ".tablename($table)." WHERE uniacid = :uniacid AND code = :code";
		$params = array(':uniacid'=>$_W['uniacid'],':code'=>$code);
		$setting = pdo_fetch($sql,$params);
		
		$item = iunserializer($setting['value']);
		$kouchu = intval($item['giveup_num']);
		
		$shengyu = $xinyu - $kouchu;
		
		if(!empty($user['forbid'])){
		    $return = array();
		    $return['status'] = 1;
		    $return['message'] = '系统检测，您已违反本平台相关规则，已被禁止！请联系管理员解封！';
		    $return['url'] = $this->createMobileUrl('home');
		    
		    $return['data'] = $runner;
		    die(json_encode($return));
		}
		
		if($shengyu > 0 ){
			$return = array();
			$return['status'] = 0;
			$return['url'] = $this->createMobileUrl('runner_xinyu');
			die(json_encode($return));
		}else{
			$return = array();
			$return['status'] = 1;
			$return['message'] = '信誉度小于'.$kouchu.',暂时不能接单，请前往充值';
			$return['url'] = $this->createMobileUrl('runner_xinyu');
			$return['data'] = $runner;
			die(json_encode($return));
		}
		
	}
}